package entity

import (
	"errors"
	"gin/common/db/config"
	"github.com/dgrijalva/jwt-go"
)

type LoginBody struct {
//	*jwt.StandardClaims
	UserId   int    //`gorm:"column:user_id"`
	DeptId   int   // `gorm:"column:dept_id"`
	UserName string //`gorm:"column:user_name"`
	NickName string `gorm:"column:nick_name"`
	Password string `gorm:"column:password"`
	Code     string `gorm:"column:code"`
	Uuid     string //`gorm:"column:uuid"`
	Token    string
}

// JwtClaims 创建自己的Claims
type JwtClaims struct {
	*jwt.StandardClaims
	//用户编号
	Uuid      string
	UserName string
}

// 登录的参数
type UserLogin struct {
	UserName string //`json:"userName"` //用户名
	Password string //`json:"password"`  //密码，对明文密码进行sha256
}

var (
	//盐
	secret                 = []byte("wondersafebox")                   // 后续加密增加盐增加复杂度
	TokenExpired     error = errors.New("Token is expired")            // token错误类型提炼
	TokenNotValidYet error = errors.New("Token not active yet")        // token错误类型提炼
	TokenMalformed   error = errors.New("That's not even a token")     // token错误类型提炼
	TokenInvalid     error = errors.New("Couldn't handle this token:") // token错误类型提炼
)



func (LoginBody) TableName() string {
	return "sys_user"
}

func init() {
	config.GormDb.AutoMigrate(&LoginBody{})
}

